Imports System
Imports System.Data
Imports Bring2mind.DNN.Modules.UserFiles.Data

Namespace Bring2mind.DNN.Modules.UserFiles.Business

#Region "FilesInfo"
	Public Class FilesInfo
	
		' local property declarations
		Dim _id as Integer
		Dim _dateSubmitted as Date
		Dim _fileLength as Integer
		Dim _fileName as String
		Dim _portalId as Integer
		Dim _userId as Integer
		
#Region "Constructors"
        Public Sub New()
        End Sub

        Public Sub New(ByVal id As Integer, ByVal dateSubmitted As Date , ByVal fileLength As Integer , ByVal fileName As String , ByVal portalId As Integer , ByVal userId As Integer)
            Me.DateSubmitted = DateSubmitted
            Me.FileLength = FileLength
            Me.FileName = FileName
            Me.id = id
            Me.PortalId = PortalId
            Me.UserId = UserId
        End Sub
#End Region
		
#Region "Public Properties"
		Public Property id() as Integer
			Get
				Return _id
			End Get
			Set(ByVal Value as Integer)
				_id = Value
			End Set
		End Property
		
		Public Property DateSubmitted() as Date 
			Get
				Return _dateSubmitted
			End Get
			Set(ByVal Value as Date)
				_dateSubmitted = Value
			End Set
		End Property

		Public Property FileLength() as Integer 
			Get
				Return _fileLength
			End Get
			Set(ByVal Value as Integer)
				_fileLength = Value
			End Set
		End Property

		Public Property FileName() as String 
			Get
				Return _fileName
			End Get
			Set(ByVal Value as String)
				_fileName = Value
			End Set
		End Property

		Public Property PortalId() as Integer 
			Get
				Return _portalId
			End Get
			Set(ByVal Value as Integer)
				_portalId = Value
			End Set
		End Property

		Public Property UserId() as Integer 
			Get
				Return _userId
			End Get
			Set(ByVal Value as Integer)
				_userId = Value
			End Set
		End Property
#End Region
	End Class
#End Region
	
#Region "FilesController"
	Public Class FilesController
		
		Public Function GetFiles(ByVal id As Integer,ByVal portalId as Integer) As FilesInfo
			
   Return CType(DotNetNuke.Common.Utilities.CBO.FillObject(DataProvider.Instance().GetFiles(id, portalId), GetType(FilesInfo)), FilesInfo)

		End Function


		Public Function AddFiles(ByVal objFiles As FilesInfo) As Integer
			
			Return CType(DataProvider.Instance().AddFiles(objFiles.DateSubmitted, objFiles.FileLength, objFiles.FileName, objFiles.PortalId, objFiles.UserId), Integer)

		End Function
	
		Public Sub UpdateFiles(ByVal objFiles As FilesInfo)
			
			DataProvider.Instance().UpdateFiles(objFiles.id, objFiles.DateSubmitted, objFiles.FileLength, objFiles.FileName, objFiles.PortalId, objFiles.UserId)
			
		End Sub
		
		Public Sub DeleteFiles(ByVal id As Integer)
			
			DataProvider.Instance().DeleteFiles(id)
		
		End Sub

  'created
  Public Function GetFileByFilename(ByVal FileName As String, ByVal UserId As Integer, ByVal portalId As Integer) As FilesInfo

   Return CType(DotNetNuke.Common.Utilities.CBO.FillObject(DataProvider.Instance().GetFileByFilename(FileName, UserId, portalId), GetType(FilesInfo)), FilesInfo)

  End Function



 End Class
#End Region



End Namespace
